/************************************************************************/
/* 
File: main.c
*Auther: 
	Henry
*Create Date:
	5-8-2008 
*Modifications:
	5-8-2008	Henry	Create
*Description:
	Contain main() function.                                                   
*/
/************************************************************************/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "encrypt.h"

//#define USER_CHECK

#ifdef USER_CHECK
#define USER_PASSWORD "Henry"
#endif

int main(int argc, void *argv[])
{
	int select;	

	printf("*************************************************\n");
	printf("*    Author: Henry                              *\n");
	printf("*    Date: 02-02-2009                           *\n");
	printf("*    Version: 1.2                               *\n");
	printf("*    Description: Code and decode a file.       *\n");
	printf("*************************************************\n\n");

#ifdef USER_CHECK
	while (1) {	
		unsigned char password[MAX_PASSWORD_LENTH];
		printf("Please enter the user password.\n>:");
		scanf("%s", password);
		if (0 == strcmp(password, USER_PASSWORD)) {
			break;
		}
	}
#endif

	while(1){	
		printf("\n(1) Press 1 to code file;\n");
		printf("(2) Press 2 to decode file;\n");
		printf("(3) Press other keys to quit.\n>:");
		scanf("%d", &select);
		if (select == 1) {		
			if(0 != code())
				printf("Coding file failed!\n");
			else
				printf("File has been successfully coded.\n");		
		}
		else if (select == 2) {
			if(0 != decode())
				printf("Decoding file failed!\n");
			else
				printf("File has been successfully decoded.\n");		
		}
		else
			return 0;		
	}
	return 1;
}

